<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<%@ page import='com.handels.bean.*' %>
<%@ page import='com.handels.core.*' %>
<%@ page import='com.handels.util.*' %>
<%@ page import='java.util.*' %>
<%@ page import='java.lang.*' %>
<tiles:insert template="../templates/default_SemMenu.jsp">	
  <tiles:put name="title" type="string" value="Alterar Senha" />
  <tiles:put name="header" type="string">
	<script type="text/javascript">
		var elementSelected = null;
  		var method = null;
  		var myActionForm = null;

  		function setMethod(value)
  		{  			
  			method = null;
  			method = value;
  		}
  		
  		function validaForm()
  		{  	
  			
  			    if(method == 'return_action')
  			    {
  				    var temp = (document.forms[0].action).split('=');
					myActionForm = temp[0];
					document.forms[0].action = myActionForm +"="+ method; 
					return true;  
  			    }
		  		else if(document.forms[0].login.value == 0)
		  		{
		  			alert("adicione um valor no campo Login!");
		  			return false;
		  		}
		  		else if(document.forms[0].senha.value == 0)
		  		{
		  			alert("adicione um valor no campo Senha!");
		  			return false;
		  		}	
		  		else if(document.forms[0].novaSenha.value == 0)
		  		{
		  			alert("adicione um valor no campo NovaSenha!");
		  			return false;
		  		}
		  		else
		  		{
					var temp = (document.forms[0].action).split('=');
					myActionForm = temp[0];
					document.forms[0].action = myActionForm +"="+ method; 
					return true;  		  			  			  					  		
		  		}	
  			
  		}
  	</script> 
  </tiles:put>
  <tiles:put name="body" type="string">
     <%
	  String msgSuccess = ((session.getAttribute("msgSuccess") != null && !session.getAttribute("msgSuccess").equals(""))?session.getAttribute("msgSuccess"):"").toString();		
		session.removeAttribute("msgSuccess");
	 
	 String msgError = ((session.getAttribute("msgError") != null && !session.getAttribute("msgError").equals(""))?session.getAttribute("msgError"):"").toString();		
		session.removeAttribute("msgError");
    %>
	<html:form action="logonForm.do?dispatch=" onsubmit="return validaForm(this);" method="post" target="_self">
            <table id="tabelaMensagem" cellpadding="0" cellspacing="0" border="0" align="center">
               <tr>
               <%
                 if (msgError!=null){
               
               %>
			        <td>
					    <span class="c_redMsg"><%=msgError%></span>
				   </td>
				   
			   <%
			    } else{
			   %>
				   <td>
					    <span class="c_blue"><%=msgSuccess%></span>
				   </td>
				<%
				}
				%>   
			   </tr>
			  
            
            <table>

			<table id="tabelaFormulario" cellpadding="0" cellspacing="0" border="0" align="center">
				<tr>
					<td>
						
						<table cellpadding="1" cellspacing="1" border="0">
							<tr>
								<td>Login: </td>
								<td>
									<html:text property="login" styleClass="inputText" value = "" size ="32" maxlength ="30" />
								</td>
							</tr>
							<tr>
								<td>Senha Atual: </td>
								<td>
									<html:password property="senha" styleClass="inputText" value = "" size ="10" maxlength ="10" />
								</td>
							</tr>	
							<tr>
								<td>Senha Nova: </td>
								<td>
									<html:password property="novaSenha" styleClass="inputText" value = "" size ="10" maxlength ="10" />
								</td>
							</tr>				
						</table>
					</td>
				</tr>
			</table>
			<table cellpadding="0" cellspacing="0" border="0" id="tabelaRodape">
				<tr>
					<td colspan="4">
						<hr class="hr"></hr>
					</td>
				</tr>
				<tr>
					<td colspan="4">
						
							<input type="submit" class="BtGeral" onclick="setMethod('return_action');" value="Voltar" />
							<input type="submit" class="BtGeral" onclick="setMethod('update_action');" value="Alterar" />
					</td>
				</tr>
			</table>	
	</html:form>	
  </tiles:put>
</tiles:insert>